﻿//初始化
if (typeof ($) != "undefined") {
    $(document).ready(function () {
        //获取员工姓名
        $("#EmpName").attr("disabled", true).css("background", "whitesmoke");
        GetEmpcodeByEmpID($("#EmployeeID").val());
        $("#WorkDate").attr("disabled", true).css("background", "whitesmoke");
        $("#BeginCardDateTime").attr("value", instance[0].BeginCardDateTime);
        $("#EndCardDateTime").attr("value", instance[0].EndCardDateTime);

        $("#BeginTime").val($("#BeginCardDateTime").val().split(" ")[1]);
        $("#EndTime").val($("#EndCardDateTime").val().split(" ")[1]);

        $("#WorkTimeID").attr("value", instance[0].WorkTimeID);
        $("#WkStatus").attr("value", instance[0].WkStatus);

        $("#LeaveTime").attr("disabled", true).css("background", "whitesmoke");

        //获取提报人employeeId
        YAHOO.util.Connect.asyncRequest('POST', "../EHR/GetCurrentUser.aspx", {
            success: function (res) {
                try {
                    //debugger;
                    var str = res.responseText;
                    if (str != "-1") {
                        var token = str.split('_');
                        instance[0].EditWho = token[0];
                    }
                }
                catch (e) {
                }
                finally {

                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);

    });
}
instance[0].EditDate = new Date();
instance[0].IsEdite = 'Y';

function fnClacLeaveTime() {
    var LeaveTime = parseFloat($("#BinJiaTime").val()) + parseFloat($("#ShiJiaTime").val()) + parseFloat($("#NianJiaTime").val()) + parseFloat($("#HunJiaTime").val()) + parseFloat($("#SangJiaTime").val()) + parseFloat($("#ChanJiaTime").val()) + parseFloat($("#ChanJianJiaTime").val()) + parseFloat($("#PeiChanJiaTime").val()) + parseFloat($("#GongshanJiaTime").val()) + parseFloat($("#FaDingJiaTime").val()) + parseFloat($("#TiaoxiuTime").val()) + parseFloat($("#TripTime").val()) + parseFloat($("#OutwardTime").val());
    //alert(LeaveTime);
    $("#LeaveTime").val(LeaveTime)
}

//获取员工姓名
function GetEmpcodeByEmpID(empId) {
    var url = "../Extend/AjaxData/jsonlist.aspx?entity=V_hrEmployee&condition=ID='" + empId + "'";
    $.get(url, function (d, s) {
        var list = eval("(" + d + ")");
        for (var o in list.rows) {
            var t = list.rows[o].CName;
            if (typeof (t) != "undefined") {
                $("#EmpName").val(t);
            }
        }
    });
}

var setBeginTime = function () {
    if ($("#BeginTime").val() != "") {
        $("#BeginCardDateTime").val($("#WorkDate").val() + $("#BeginTime").val())
    }
}

var setEndTime = function () {
    if ($("#EndTime").val() != "") {
        $("#EndCardDateTime").val($("#WorkDate").val() + $("#EndTime").val())
    }
}

var fnCheckData = function () {
    try {

        if ($("#WorkDate").val() == "") {
            return "工作日不能为空！";
        }
    }
    catch (e)
     { }
}
